package com.wjs.controller;

import com.wjs.entity.User;
import com.wjs.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;

@Controller
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService userService;

    @RequestMapping("/login")
    public String login(User user, HttpSession session){
        User user1 = userService.login(user);
        if (user1!=null){
            session.setAttribute("username",user1.getUsername());
            return "redirect:/phone/selectAll.do";
        }else {
            return "/index.jsp";
        }
    }
}
